<?php
/**
 * @author Carlos Roberto Alvarez Muñoz <ingcram@gmail.com>
 */
class Familias extends ActiveRecord{
	
    public $debug = FALSE;

	public function initialize(){ 	        		
    }
    
    public function actualizar($familia)
    {
        return $this->update($familia);
    }
    
    public function getActivo($familia_id)
    {
        return $this->find($familia_id);
    }
    
    public function getByNombre($categoria_descripcion)
    {        
        return $this->find_first("descripcion = '$categoria_descripcion' ");
    }
	
    public function getActivos($page=1)
    {
        return $this->paginate("page: $page", 'order: id desc','conditions: id > 0');
    }
	
    public function guardar($familia=null)
    {
    	
    	$this->created_user = "0";
    	$this->updated_user = "0";
        return $this->save($familia);
    }
	
    public function buscar($familia_id)
    {
        return $this->find($familia_id);
    }
	
    public function eliminar($familia_id)
    {
        return $this->delete($familia_id);
    }
    
    public function getIdByCodigo($familia_codigo)
    {
        $this->find_first("codigo = '$familia_codigo'");
        return $this->id;
        
    }
    
	public function getFamilias()
    {
        return $this->find("conditions: id > 0");
        
        
    }
}